<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :deleteApiName="deleteApiName"
                :saveAuthName="saveAuthName"
                :deleteAuthName="deleteAuthName"
                :templateDownloadApiName="templateDownloadApiName"
                :importApiName="importApiName"
                :showAttrs="showAttrs"
    >
    </table-view>
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <modelinfo-add-or-update v-if="modelInfoVisible" ref="modelInfo"></modelinfo-add-or-update>
  </div>
</template>

<script>
import AddOrUpdate from './modeladd-add-or-update'
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'
import ModelinfoAddOrUpdate from '@/views/modules/model/modelinfo-add-or-update'

export default {
  mixins: [basicMixins],
  data() {
    return {
      modelInfoVisible: false,
      searchAttrs: {
        modelInfoId: {
          type: 'autoComplete',
          placeholder:'模具编号',
          querySearchApiName: 'modelApi/getModelInfoList'
        },
        productNo: {
          label: '产品名称',
          placeholder: '请输入产品名称',
        },
        modelFactory: {
          placeholder:'模具厂'
        },
        dateTimeRange: {
          type: 'date',
          dateType: 'daterange',
          clearable: true
        }
      },
      primaryKey: 'id',
      listApiName: 'modelApi/listModelAdd',
      deleteApiName: 'modelApi/deleteModelAdd',
      saveAuthName: 'model:modeladd:save',
      deleteAuthName: 'model:modeladd:delete',
      templateDownloadApiName: 'modelApi/templateDownloadModelAdd',
      importApiName: 'modelApi/importModelAdd',
      showAttrs: {
        modelShelfNo: {label: '货架', width:120},
        modelInfoNo: {label: '模具号', width:120},
        productNo: {label: '产品名称', width:120},
        modelAddType: {
          label: '入库方式',
          type: 'radio',
          items: [
            {value: 3, text: '生产使用', tagType: 'success'},
            {value: 0, text: '采购'},
            {value: 1, text: '返回模具厂', tagType: 'danger'},
            {value: 2, text: '外调', tagType: 'warning'},
            {value: 4, text: '客户提供'},
            {value: 5, text: '从客户拉回'},
          ]
        },
        modelCalibre: {label: '口径'},
        productWeight: {label: '克重'},
        modelType: {label: '生产/试样模',
          type: 'radio',
          items: [
            {value: 0, text: '试样模' },
            {value: 1, text: '生产模',tagType: 'success'}
          ]},
        // modelCategoryName: {label: '模具类别'},
        // handlingPeople: {label: '经手人'},
        successMo: {label: '成模'},
        primaryMo: {label: '初模'},
        menTou: {label: '闷头'},
        louDou: {label: '漏斗'},
        kouZi: {label: '口子'},
        xinZi: {label: '芯子'},
        qiTou: {label: '气头'},
        qianPian: {label: '钳片'},
        lengQue: {label: '冷却'},
        dayTime: {label: '入库时间',type: 'date', width:100},
        localFactoryModel: {label: '本厂模具', width:100},
        generateKouMo: {label: '通用口模', width:100},
        clientName: {label: '客户'},
        remark: {label: '备注'},
        remarkTwo: {label: '备注2'},

      }
    }
  },
  methods:{
    openModelInfoDialog(cb) {
      this.modelInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.modelInfo)) {
          this.$refs.modelInfo.init(null, {status: 1}, cb)
        }
      })
    }
  },
  components: {
    ModelinfoAddOrUpdate,
    AddOrUpdate,
    tableView
  }
}
</script>
